<%--
  Created by IntelliJ IDEA.
  User: acoffee
  Date: 2021/11/1
  Time: 11:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>商品列表_蜗牛图书商城</title>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/index.css">
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.js"></script>

    <script>
        var getParam = (function () {
            var url = window.document.location.href.toString(); //获取的完整url
            var u = url.split("?");
            if (typeof (u[1]) == "string") {
                u = u[1].split("&");
                var get = {};
                for (var i in u) {
                    var j = u[i].split("=");
                    get[j[0]] = j[1];
                }
                return get;
            } else {
                return {};
            }
        })();

        $(function () {
            $.post("${pageContext.request.contextPath}/category/queryAllCategory", "", function (data) {
                var goodsType = $("#goodsType");
                var str = "";
                for (var i in data) {
                    str += '<li><a href="${pageContext.request.contextPath}/goods/queryPageByCid?cid=' + data[i].id + '&currentPage=1">' + data[i].name + '</a></li>'
                }
                goodsType.append(str);
            }, "json")
        });

        var cid = getParam.cid;

        function firstPage() {
            location.href = "${pageContext.request.contextPath}/goods/queryPageByCid?cid=" + cid + "&currentPage=1";
        }

        function lastPage() {
            location.href = "${pageContext.request.contextPath}/goods/queryPageByCid?cid=" + cid + "&currentPage=" + $("#totalPage").text();
        }

        function showGoodsByPage(num) {
            location.href = "${pageContext.request.contextPath}/goods/queryPageByCid?cid=" + cid + "&currentPage=" + num;
        }

        $(function () {
            $.post("${pageContext.request.contextPath}/goods/queryRankGoods", "cid=" + cid, function (data) {
                var ranklist = $("#ranklist");
                var str = "";

                for (var i in data) {
                    str += '<li>' +
                        '<span>' + (+i + 1) + '</span>' +
                        '<a class="p_name" href="${pageContext.request.contextPath}/goods/details?id='+data[i].id+'" target="_blank" alt="' + data[i].name + '" title="' + data[i].name + '">' + data[i].name + '</a>' +
                        '</li>';
                }
                ranklist.append(str);
            }, "json")
        })
    </script>
</head>
<body class="index">
<div class="container">
    <%@ include file="/common/page_top.jsp" %>

<%--<div class="header" id="header">--%>
        <%--<h1 class="logo">--%>
            <%--<a title="" style="background:url(${pageContext.request.contextPath}/images/logo.png);"--%>
               <%--href="${pageContext.request.contextPath}/pages/index.jsp">电子商务平台</a>--%>
        <%--</h1>--%>
        <%--<!-- <ul class="shortcut">--%>
            <%--<li class="first"><a href="ucenter/">个人中心</a></li>--%>
            <%--<li><a href="ucenter/">我的订单</a></li>--%>
        <%--</ul>--%>
        <%--<p class="loginfo">--%>


              <%--[<a href="user?opr=tologin">登录</a>--%>
                <%--<a class="reg" href="user?opr=toreg">免费注册</a>]--%>

        <%--</p> -->--%>
        <%--<ul class="shortcut">--%>
            <%--<li class="first"><a href="${pageContext.request.contextPath}/pages/personal.jsp">个人中心</a></li>--%>
            <%--<li><a href="myOrders.html">我的订单</a></li>--%>
        <%--</ul>--%>
        <%--<p class="loginfo">${user.username}[<a href="javaScript:logout()">安全退出</a>]</p>--%>
    <%--</div>--%>

    <%--<div class="navbar">--%>
        <%--&lt;%&ndash;<ul id="goodsType">&ndash;%&gt;--%>
            <%--&lt;%&ndash;<li><a href="goods.html?gtid=0">首页</a></li>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<!-- <li><a href="#">IT技术</a></li>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<li><a href="#">小说文学</a></li>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<li><a href="#">历史传记</a></li>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<li><a href="#">生活</a></li>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<li><a href="#">经营管理</a></li> -->&ndash;%&gt;--%>
            <%--&lt;%&ndash;<li><a href="goods.html?gtid=1">IT技术</a></li>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<li><a href="goods.html?gtid=2">历史传记</a></li>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<li><a href="goods.html?gtid=3">小说</a></li>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<li><a href="goods.html?gtid=4">生活</a></li>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<li><a href="goods.html?gtid=5">经营管理</a></li>&ndash;%&gt;--%>
        <%--&lt;%&ndash;</ul>&ndash;%&gt;--%>
        <%--<div class="mycart">--%>
            <%--<dl>--%>
                <%--<dt>--%>
                    <%--<a href="${pageContext.request.contextPath}/pages/cart.jsp">购物车</b>--%>
                    <%--</a>--%>
                <%--</dt>--%>
                <%--<dd>--%>
                    <%--<a href="cart.html">去结算</a>--%>
                <%--</dd>--%>
            <%--</dl>--%>
            <%--<!--购物车浮动div 开始-->--%>
            <%--<div class="shopping" id="div_mycart" style="display: none;">--%>
                <%--<dl class="cartlist" id="shopcarDiv">--%>
                <%--</dl>--%>
            <%--</div>--%>
        <%--</div>--%>
    <%--</div>--%>
    <div class="searchbar">
        <div class="allsort">
            <a href="javascript:void(0);"></a>
            <!--总的商品分类-开始-->
            <ul class="sortlist" id="div_allsort" style="display: none">
                <li><h2><a href="goods.html?gtid=1">IT技术</a></h2></li>
                <li><h2><a href="goods.html?gtid=2">历史传记</a></h2></li>
                <li><h2><a href="goods.html?gtid=3">小说</a></h2></li>
                <li><h2><a href="goods.html?gtid=4">生活</a></h2></li>
                <li><h2><a href="goods.html?gtid=5">经营管理</a></h2></li>
            </ul>
        </div>
        <script>

        </script>

        <div class="searchbox">
            <!-- <form method='get' action='/search'> -->
            <input class="text" type="text" name="q" autocomplete="off" placeholder="" id="word"> <input
                class="btn" type="button" value="搜索" id="search-btn">
            <!-- </form> -->

        </div>
        <div class="hotwords">
            <%--热门搜索：IT--%>
        </div>
    </div>
    <div class="wrapper clearfix container_2">
        <div class="sidebar f_l">
            <!--销售排行-->
            <div class="box m_10">
                <div class="title">销售排行榜</div>
                <div class="content">
                    <ul class="ranklist" id="ranklist">
                    </ul>
                </div>
            </div>
            <!--销售排行-->
        </div>

        <div class="main f_r">
            <ul class="display_list clearfix m_10" id="goods">

                <c:forEach items="${pageBean.items}" var="goods">
                    <li class="clearfix win">
                        <div class="pic"><a title="${goods.name}"
                                            href="goodsDetail.html?gid=362" target="_self"> <img
                                src="${pageContext.request.contextPath}/${goods.image}" width="200" height="200"
                                alt="${goods.name}"
                                title="${goods.name}"></a></div>
                        <h3 class="title"><a class="p_name" href="goodsDetail.html?gid=362" target="_self"
                                             alt="${goods.name}"
                                             title="${goods.name}">${goods.name}</a> <span>总销量：${goods.salenums}</span>
                        </h3>
                        <div class="handle"><label class="btn_gray_m"><img
                                src="${pageContext.request.contextPath}/images/front/ucenter/shopping.gif"
                                width="15" height="15"><input type="button"
                                                              value="加入购物车"
                                                              onclick="addCart(362)"></label>
                        </div>
                        <div class="price" style="padding-top:18px">￥${goods.salesPrice}<s>￥${goods.marketprice}</s>
                        </div>
                    </li>
                </c:forEach>

            </ul>
            <div class="pages_bar" id="page-bar">
                <a href="javascript:void(0)" onclick="firstPage()">首页</a>

                <c:forEach begin="1" end="${pageBean.totalPage}" var="num">
                    <a class="current_page" href="javascript:void(0)" onclick="showGoodsByPage(${num})">${num}</a>
                </c:forEach>

                <a href="javascript:void(0)" onclick="lastPage()">尾页</a>

                当前第<span id="currentPage">${pageBean.currentPage}</span>页/共<span
                    id="totalPage">${pageBean.totalPage}</span>页
            </div>
        </div>
    </div>
    <div class="help m_10">
        <div class="cont clearfix">
            <dl>
                <dt>
                    <a href="">购物指南</a>
                </dt>
                <dd>
                    <a href="">订单状态</a>
                </dd>
                <dd>
                    <a href="">购物流程</a>
                </dd>
            </dl>
            <dl>
                <dt>
                    <a href="">支付帮助</a>
                </dt>
                <dd>
                    <a href="">支付帮助</a>
                </dd>
                <dd>
                    <a href="">在线支付</a>
                </dd>
                <dd>
                    <a href="">货到付款</a>
                </dd>
            </dl>
            <dl>
                <dt>
                    <a href="">配送帮助</a>
                </dt>
                <dd>
                    <a href="">EMS/邮政普包</a>
                </dd>
                <dd>
                    <a href="">商品验货与签收</a>
                </dd>
                <dd>
                    <a href="">配送范围及运费</a>
                </dd>
            </dl>
            <dl>
                <dt>
                    <a href="">售后服务</a>
                </dt>
                <dd>
                    <a href="">售后服务</a>
                </dd>
                <dd>
                    <a href="">发票制度</a>
                </dd>
                <dd>
                    <a href="">退货说明</a>
                </dd>
                <dd>
                    <a href="">换货说明</a>
                </dd>
            </dl>
            <dl>
                <dt>
                    <a href="">帮助信息</a>
                </dt>
                <dd>
                    <a href="">友情链接</a>
                </dd>
                <dd>
                    <a href="">联系客服</a>
                </dd>
                <dd>
                    <a href="">找回密码</a>
                </dd>
                <dd>
                    <a href="">关于我们</a>
                </dd>
            </dl>
        </div>
    </div>
    <div class="footer">
        <p class="links">
            <a href="">关于我们</a>|<a href="">常见问题</a>|<a href="">安全交易</a>|<a href="">购买流程</a>|<a href="">如何付款</a>|<a
                href="">联系我们</a>|<a href="">合作提案</a>
        </p>
    </div>
</div>


</body>
</html>